#!/usr/bin/python
import struct
import os
import array
import sys
fn = ""
try:
    fn = sys.argv[1]
except:
    print "exception found! using soundrecord.wav"
    fn = "soundrecord.wav"
print "file:", fn

r = open(fn, 'rb')
r.seek(0, os.SEEK_END)
size = r.tell()
r.close()
sr = 8000
c = 1 # Channels
bits = 16
s = struct.pack("4sL4s4sLHHLLHH4sL","RIFF",size+36,"WAVE", "fmt ",16,1,c,sr,sr*2, 2, bits,"data", size)

w = open("header.hdr", "wb")
w.write(s)
w.close()

# use 
# $cat header.hdr file.wav > new.wav
# to generate new file
